<div class="row animate fadeIn">
    <form id="" class="form-horizontal"  method="post">
      <?php foreach($invoice_data as $inv) { ?>
      <input type="hidden" name="" id="v_invoice_id" value="<?php echo $inv->invoice_id; ?>">
        <div class="ibox-title" style="border:none;"><h5 style="color: #00afef"><i>View Invoice</i></h5>
        </div>
        <div class="ibox-content">   
          <div class="form-group">
              <label class="col-lg-2 control-label">Account No</label>
            <div class="col-lg-5">
              <input type="text" id="" name="" class="form-control" value="<?php echo $inv->account_num; ?>" readonly>
            </div>
              <label class="col-lg-2 control-label">Invoice No</label>
            <div class="col-lg-3">
              <input type="text" name="" class="form-control" value="<?php echo $inv->invoice_num; ?>" readonly>
            </div>
          </div>
          <div class="form-group">
              <label class="col-lg-2 control-label">Account Type</label>
            <div class="col-lg-5">
              <input type="text" id="" name="" class="form-control" value="<?php echo $inv->meaning; ?>" readonly>
            </div>
              <label class="col-lg-2 control-label">Invoice Date</label>
            <div class="col-lg-3">
              <input type="text" name="" class="form-control" value="<?php echo date('d-M-Y',strtotime($inv->invoice_date)); ?>" readonly>
            </div>
          </div>
          <div class="form-group">
              <label class="col-lg-2 control-label">Customer Name</label>
            <div class="col-lg-5">
              <input type="text" id="" name="" class="form-control" value="<?php echo $inv->acct_name; ?>" readonly>
            </div>
              <label class="col-lg-2 control-label">GL Date</label>
            <div class="col-lg-3">
              <input type="text" name="" class="form-control" value="<?php echo date('d-M-Y',strtotime($inv->gl_date)); ?>" readonly>
            </div>
          </div>
          <div class="form-group">
              <label class="col-lg-2 control-label">Billing Address</label>
            <div class="col-lg-5">
              <input type="text" id="" name="" class="form-control" value="<?php echo $inv->address_1; ?>" readonly></input>
            </div>
              <label class="col-lg-2 control-label">Due Date</label>
            <div class="col-lg-3">
              <input type="search" name="" id="" class="form-control" value="<?php echo date('d-M-Y',strtotime($inv->due_date)); ?>" readonly>
            </div>
          </div>
          <div class="form-group">
              <label class="col-lg-2 control-label">Charge List</label>
            <div class="col-lg-5">
              <input type="text" id="" name="" class="form-control" value="<?php echo $inv->list_name; ?>" readonly>
            </div>
              <label class="col-lg-2 control-label">Previous Balance</label>
            <div class="col-lg-3">
              <input type="text" name="" class="form-control" value="<?php echo $inv->prev_bill_bal; ?>" readonly>
            </div>
          </div>
          <div class="form-group">
              <label class="col-lg-2 control-label">Receivable Acct</label>
            <div class="col-lg-5">
              <select class="chosen-select" name="" disabled>
                <?php foreach ($rec_acct as $rec_types) { ?>
                  <option value="<?php echo $rec_types->account_id; ?>" <?php echo($rec_types->account_id == $inv->rec_acct_id ? 'selected' : ''); ?> ><?php echo $rec_types->acct_code." : ".$rec_types->acct_name; ?></option>
                <?php } ?>
              </select>
            </div>
              <label class="col-lg-2 control-label">Invoice Status</label>
            <div class="col-lg-3">
              <select style="width: 159px;" class="chosen-select" name="" disabled>
                <?php foreach ($inv_status as $lookup_stat) { ?>
                  <option value="<?php echo $lookup_stat->lookup_code; ?>" <?php echo($lookup_stat->lookup_code == $inv->inv_stat ? 'selected' : ''); ?>><?php echo $lookup_stat->meaning; ?></option>
                <?php } ?>
              </select>
            </div>
          </div>
          <div class="form-group">
              <label class="col-lg-9 control-label">Payment Status</label>
            <div class="col-lg-3">
              <p class="form-control-static"><b><?php echo $invoice_pay; ?></b></p>
            </div>
          </div>
          <div class="form-group">
              <label class="col-lg-2 control-label">Description</label>
            <div class="col-lg-5">
              <input type="text" name="" class="form-control" value="<?php echo $inv->inv_desc; ?>" readonly>
            </div>
              <label class="col-lg-2 control-label">This Invoice Total</label>
            <div class="col-lg-3">
              <input type="text" name="" class="form-control" value="<?php echo $inv->invoice_total; ?>" readonly>
            </div>
          </div>
          <div class="form-group">
              <label class="col-lg-9 control-label">This Invoice Balance</label>
            <div class="col-lg-3">
              <input type="text" name="" class="form-control" value="<?php echo $inv->invoice_balance; ?>" readonly>
            </div>
          </div>
          
        </div>
        <?php } ?>
    </form>
<!--  -->
  
      <table id="" class="table table-bordered" style="width:99%;">
        <thead>
          <tr>
            <th style="width:50px;">Line</th>
            <th style="">Charge Elements</th>
            <th style="width:120px;">Usage Quantity</th>
            <th style="width:150px;">Unit of Measure</th>
            <!-- <th style="width:50px;">Rate</th> -->
            <th style="width:50px;">Tax</th>
            <th style="width:70px;">Amount</th>
          </tr>   
          
        </thead>
        <tbody id="view_inv_line" class="animate fadeIn">
        </tbody>
    </table> 

</div>
<script>
$(document).ready(function(){ 
$(".chosen-select").chosen({width:"100%;"}); 
        var v_id = $('#v_invoice_id').val();
        $.ajax({
              type: "POST",
              url: "<?php echo base_url($this->session->userdata('forajax').'/view_invoiceLine'); ?>"+"/"+v_id,
              dataType: 'json',
          success: function(data){
                $('#view_inv_line').empty();
                var trHTML = '';
                $.each(data, function(i, item) {
                  trHTML += '<tr><td>' + data[i].line_num + '</td><td text-align:right;>' + data[i].charge_name + '</td><td text-align:right;>' + data[i].usage_qty + '</td><td text-align:right;>' + data[i].uom_name + '</td><td text-align:right;>' + data[i].tax_amt + '</td><td text-align:right;>' + data[i].line_amt + '</td></tr>';
                });
                $('#view_inv_line').append(trHTML);
              }      
        });

        $('#viewX').click(function(){
          close_view();
        });
});
</script>